<template>
  <div v-loading="loading">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="dataForm">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('标题')" prop="title">
            <el-input v-model="form.title" :placeholder="$t('标题')" show-word-limit maxlength="100" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户org_id')" prop="customerOrgId">
            <el-input v-model="form.customerOrgId" :placeholder="$t('客户org_id')" show-word-limit maxlength="32" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户数据库编码')" prop="customerSchema">
            <el-input v-model="form.customerSchema" :placeholder="$t('客户数据库编码')" show-word-limit maxlength="127" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户机构编码')" prop="customerCode">
            <el-input v-model="form.customerCode" :placeholder="$t('仅SAAS客户时有值')" show-word-limit maxlength="127" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户名称')" prop="customerName">
            <el-input v-model="form.customerName" :placeholder="$t('客户名称')" show-word-limit maxlength="100" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户请求来源IP')" prop="customerIp">
            <el-input v-model="form.customerIp" :placeholder="$t('客户请求来源IP')" show-word-limit maxlength="10" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('用户名称')" prop="userName">
            <el-input v-model="form.userName" :placeholder="$t('用户邮箱')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('用户邮箱')" prop="userEmail">
            <el-input v-model="form.userEmail" :placeholder="$t('用户邮箱')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('用户手机号')" prop="userPhone">
            <el-input v-model="form.userPhone" :placeholder="$t('用户邮箱')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('反馈时间')" prop="feedbackTime">
            <el-date-picker
              v-model="form.feedbackTime"
              clearable
              style="width: 200px"
              type="date"
              value-format="yyyy-MM-dd"
              :placeholder="$t('反馈时间')"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: right;">
      <!--保存 取消按钮-->
      <!-- <save-btn has-permi="system:manager" /> -->
      <el-button @click="cancel">取消</el-button>
    </div>
  </div>
</template>

<script>
    import { saveFeedbackManager, getFeedbackManager } from '@/api/system/feedback/feedbackManager'
    export default {
        data() {
            return {
                // 表单参数
                form: {},
                // 遮罩层
                loading: false,
                // 表单校验
                rules: {
                }
            }
        },
        created() {
        },
        methods: {
            // 初始化数据
            init(data) {
                this.loading = true
                if (data != null && data.id !== undefined) {
                    getFeedbackManager(data.id).then(response => {
                        this.form = response.data
                        this.loading = false
                    })
                } else {
                    this.reset()
                    this.loading = false
                }
            },
            // 表单重置
            reset() {
                this.form = {
                    id: undefined,

                    title: undefined,

                    remark: undefined,

                    customerType: undefined,

                    customerOrgId: undefined,

                    customerSchema: undefined,

                    customerCode: undefined,

                    customerName: undefined,

                    customerIp: undefined,

                    userName: undefined,

                    userEmail: undefined,

                    userPhone: undefined,

                    feedbackTime: undefined,

                    status: undefined

                }
                this.resetForm('form')
            },
            // 取消按钮
            cancel() {
                this.$parent.$parent.formOpen = false
                this.$parent.$parent.reset()
            },
            // 关闭form页面
            closeForm() {
                // 关闭form页面遮罩层
                this.loading = false
                // 关闭form页面
                if (this.$parent.$parent.formOpen !== undefined) {
                  this.$parent.$parent.formOpen = false
                }
                // 刷新list页面
                if (this.$parent.$parent.getList !== undefined) {
                  this.$parent.$parent.getList()
                }
            },
            /** 提交按钮 */
            submitForm: function() {
                this.$refs['form'].validate(valid => {
                    if (valid) {
                        this.loading = true
                        saveFeedbackManager(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess(this.$t('保存成功'))
                                this.closeForm()
                            } else {
                                this.msgError(response.msg)
                            }
                            this.loading = false
                        })
                    } else {
                       this.locationError(document)
                    }
                })
           }

        }

    }
</script>
